package org.example

import java.io.BufferedReader
import java.io.FileReader
import kotlin.random.Random

//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
fun main() {
    val name = "Kotlin"
    //TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
    // to see how IntelliJ IDEA suggests fixing it.
    println("Hello, $name!")

    for (i in 1..5) {
        //TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
        // for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
        println("i = $i")
    }

    // if else
    val rand = Random.nextInt(10)
    val result = if (rand >= 5) "大" else "小"
    println("result: $result")
    println("result: ${if (rand >= 5) "大" else "小"}")

    val score = Random.nextInt(101)
    val scoreStr = when {
        score >= 80 -> "优秀"
        score >= 60 -> "及格"
        else -> "不及格"
    }
    println("score: $scoreStr")

    val color = Color.entries[Random.nextInt(Color.entries.size)]
    val colorStr = when (color) {
        Color.RED -> "红色"
        Color.GREEN -> "绿色"
        Color.BLUE -> "蓝色"
        Color.OTHER -> "其他颜色"
    }
    println("color: $color, colorStr: $colorStr")

    val reader = BufferedReader(FileReader("settings.gradle.kts"))
    while (true) {
        val line = reader.readLine()
        if (line == null) {
            break
        }
        println(line)
    }
    for (i in "hello") {
        println(i)
    }

//    val str = (readlnOrNull() ?: "").trim()
//    println("input: $str")

    Player.randomPlayer("12345")?.kick()
    Player.randomPlayer("123")?.kick()

}

enum class Color {
    RED, GREEN, BLUE, OTHER
}